package com.tgz.controller;

//import com.tgz.config.MyVar;
import com.tgz.config.MyVar;
import com.tgz.model.Bscreen;
import com.tgz.model.Phone;
import com.tgz.service.IBscreenService;
import com.tgz.service.IPhoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author hsj
 * @description:
 * @date 2022/12/22 16:30
 */
@Controller
public class PageController {
    private final static String TITLE = "云南特盖则科技有限公司2022年会在线签到系统";
    private final static String B_SCREEN_TITLE = "云南特盖则科技有限公司2022年会扫码送祝福";
    @Resource
    private IPhoneService iPhoneService;
    @Resource
    private IBscreenService iBscreenService;
    @Autowired
    private MyVar myVar;

//    @RequestMapping(value = "/phoneSign",method = RequestMethod.GET)
//    public String phoneSign(Model model) {
//        model.addAttribute("title", TITLE);
//        return "test/phoneSign";
//    }
//
//    @RequestMapping(value = "/findAllPhone",method = RequestMethod.GET)
//    public String findAllPhone(Model model) {
//        model.addAttribute("title", TITLE);
//        model.addAttribute("findAllPhone", iPhoneService.findAllPhone());
//        return "test/findAllPhone";
//    }




    @RequestMapping(value = "/mobile-form.html",method = RequestMethod.GET)
    public String mobileForm(Model model) {
        model.addAttribute("title",TITLE);
        return "mobile-form";
    }
    @RequestMapping(value = "/mobile-success.html",method = RequestMethod.GET)
    public String mobileSuccess(Model model) {
        model.addAttribute("title", TITLE);
        return "mobile-success";
    }
    @RequestMapping(value = "/mobile-fail.html",method = RequestMethod.GET)
    public String mobileFail(Model model) {
        model.addAttribute("title", TITLE);
        return "mobile-fail";
    }
    @RequestMapping(value = "/mobile-list.html",method = RequestMethod.GET)
    public String mobileList(Model model) {
        List<Phone> allPhone = iPhoneService.findAllPhone();
        int allSize = 0;
        if(!ObjectUtils.isEmpty(allPhone)){
            allSize = allPhone.size();
        }
        model.addAttribute("allPhone", allPhone);
        model.addAttribute("allSize", String.format("共 %s 条",allSize));
        model.addAttribute("title", TITLE);
        return "mobile-list";
    }






    @RequestMapping(value = "/b-screen-form.html",method = RequestMethod.GET)
    public String bScreenForm(Model model) {
        model.addAttribute("title",B_SCREEN_TITLE);
        return "b-screen-form";
    }
    @RequestMapping(value = "/b-screen-success.html",method = RequestMethod.GET)
    public String bScreenSuccess(Model model) {
        model.addAttribute("title", B_SCREEN_TITLE);
        return "b-screen-success";
    }
    @RequestMapping(value = "/b-screen-fail",method = RequestMethod.GET)
    public String bScreenFail(Model model) {
        model.addAttribute("title", B_SCREEN_TITLE);
        return "b-screen-fail";
    }

    @RequestMapping(value = "/b-screen.html",method = RequestMethod.GET)
    public String bScreen(Model model) {
        List<Bscreen> allBScreen = iBscreenService.findAllBscree();
        model.addAttribute("allBScreen", allBScreen);
        model.addAttribute("endpoint", myVar.getEndpoint());
        model.addAttribute("topicChannel", myVar.getTopicChannel());
        model.addAttribute("title", B_SCREEN_TITLE);
        return "b-screen";
    }
    @RequestMapping(value = "/b-screen-list.html",method = RequestMethod.GET)
    public String bScreenList(Model model) {
//        List<Bscreen> allBScreen = iBscreenService.findAllBscreeWithNoCheckStatus();
//        int allSize = 0;
//        if(!ObjectUtils.isEmpty(allBScreen)){
//            allSize = allBScreen.size();
//        }
//        model.addAttribute("allBScreen", allBScreen);
//        model.addAttribute("allSize", String.format("共 %s 条",allSize));
        model.addAttribute("endpoint", myVar.getEndpoint());
        model.addAttribute("topicChannel", myVar.getTopicChannel());
        model.addAttribute("title", B_SCREEN_TITLE);
        return "b-screen-list";
    }



    /**
     * @Description:user单聊：一对一
     * @author HeShengjin 2356899074@qq.com
     * @date 2022/12/26 10:02
     */
    @RequestMapping(value = "/one-to-one-chat.html",method = RequestMethod.GET)
    public String oneToOneChat(Model model) {
        model.addAttribute("endpointUser", myVar.getEndpointUser());
        model.addAttribute("topicUser", myVar.getTopicUser());
        model.addAttribute("topicUserChannel", myVar.getTopicUserChannel());
        model.addAttribute("title", B_SCREEN_TITLE);
        return "one-to-one-chat";
    }
}
